{extend name="public:base" /}
{block name="content"}
<link rel="stylesheet" href="__CSS__/bootstrapValidator.min.css">
<link rel="stylesheet" href="__CSS__/AdminLTE.min.css">
<style type="text/css">
    input.error { border: 1px solid red; }
    label.error {
        background:url("./demo/images/unchecked.gif") no-repeat 0px 0px;

        padding-left: 16px;

        padding-bottom: 2px;

        font-weight: bold;

        color: #EA5200;
    }
    .f_g_box{
        flex-flow: row wrap;
    }
    label.checked {
        background:url("./demo/images/checked.gif") no-repeat 0px 0px;
    }
</style>
<div class="back_btn">
    <!-- 返回按钮 -->
    <button class="btn btn_color" type="button" style="outline: none;">
        <a href="{:url('index/index')}"><span class="glyphicon glyphicon-arrow-left" style="color:#3c8dbc;font-size: 18px;"></span></a>
    </button>
    <button type="button" class="btn btn-info btn-xs pull-right " style="margin: 10px 10px;">
        <a href="{:url('index')}">返回首页</a>
    </button>
</div>
<div class="row_box">
    <div class="col_box">
        <div class="box-header" data-original-title="" style="height: 30px;">
            <span><i class="glyphicon glyphicon-plus"></i>修改订单</span>
        </div>
        <div class="input_box">
            <form action="" id="commentForm" method="post">
                <br>
                <br>
                <input type="hidden" name="id" value="{$info.id}" id="id" >
                <i><h4>顾客信息:</h4></i>
                <br>
                <div class="form-group f_g_box">
                    <label>姓名</label>
                    <input type="text" name="name" value="{$info.name}">
                </div>
                <div class="form-group f_g_box">
                    <label>电话(妈妈)</label>
                    <input type="text" name="maphone" value="{$info.maphone}" id="maphone">
                </div>
                <div class="form-group f_g_box">
                    <label>电话(其他)</label>
                    <input type="text" name="otherphone" {neq name='info.otherphone' value='0'}value="{$info.otherphone}"{/neq} id="otherphone">
                </div>
                <div class="form-group f_g_box">
                    <label>微信</label>
                    <input type="text" name="weixin" {neq name='info.weixin' value='0'}value="{$info.weixin}"{/neq} id="weixin">
                </div>
                <div class="form-group f_g_box">
                    <label>QQ</label>
                    <input type="text" name="qq" {neq name='info.qq' value='0'}value="{$info.qq}"{/neq} id="qq">
                </div>
                <div class="form-group f_g_box">
                    <label>预产期</label>
                    <input type="text" onclick="layui.laydate({elem: this, festival: true})"  id="yctime"  name="yctime" {neq name="info.yctime" value="1970-01-01"}value="{$info.yctime}"{/neq}>
                </div>
                <div class="form-group f_g_box">
                    <label>照片分类</label>
                    <select class="form-control" name="fenlei">
                        <option value="">请选择</option>
                        {volist name='fenlei' id='data'}
                        <option value="{$data.id}" {eq name="info['fenlei']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>业务状态</label>
                    <select class="form-control" name="ywstate">
                        <!--{foreach name="states" item="vo" key="k" }-->
                        <!--<option value="{$k}" {eq name="info['ywstate']" value="$k"}selected="selected"{/eq} >{$vo}</option>-->
                        <!--{/foreach}-->
                        {volist name='state' id='data'}
                        <option value="{$data.id}" {$data.status}{eq name="info['ywstate']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>

                <br>
                <br>
                <i><h4>邀约和摄影场信息：</h4></i>
                <br>
                <div class="form-group f_g_box">
                    <label>邀约客服</label>
                    <select class="form-control" name="yykf">
                        <option value="">请选择</option>
                        {volist name='yykf' id='data'}
                        <option value="{$data.id}" {eq name="info['yykf']" value="$data.id"}selected="selected"{/eq} >{$data.username}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>预约场馆</label>
                    <select class="form-control" name="yycg">
                        <option value="">请选择</option>
                        {volist name='yycg' id='data'}
                        <option value="{$data.id}" {eq name="info['yycg']" value="$data.id"}selected="selected"{/eq} >{$data.title}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>预约拍摄时间</label>
                    <input type="text" name="yypstime"  onclick="laydate()" {neq name="info.yypstime" value="1970-01-01"}value="{$info.yypstime}"{/neq}>
                </div>
                <div class="form-group f_g_box">
                    <label>取消拍摄时间</label>
                    <input type="text" name="qxpstime"  onclick="laydate()" {neq name="info.qxpstime" value="1970-01-01"}value="{$info.qxpstime}"{/neq}>
                </div>
                <div class="form-group f_g_box">
                    <label>未到拍摄时间</label>
                    <input type="text" name="wdpstime"  onclick="laydate()" {neq name="info.wdpstime" value="1970-01-01"}value="{$info.wdpstime}"{/neq}>
                </div>
                <div class="form-group f_g_box">
                    <label>追踪日期</label>
                    <input type="text" name="zztime"  onclick="laydate()" {neq name="info.zztime" value="1970-01-01"}value="{$info.zztime}"{/neq}>
                </div>
                <div class="form-group f_g_box">
                    <label>邀约备注</label>
                    <textarea type="text" class="form-control" rows="5" name="yybz" >{$info.yybz}</textarea>
                </div>
                <div class="form-group f_g_box">
                    <label>拍摄备注</label>
                    <textarea type="text" rows="5" name="psbz" >{$info.psbz}</textarea>
                </div>
                <br>
                <br>
                <i><h4>渠道信息：</h4></i>
                <br>
                <div class="form-group f_g_box">
                    <label>收集渠道</label>
                    <select class="form-control" name="qudao">
                        <option value="">请选择</option>
                        {volist name='qudao' id='data'}
                        <option value="{$data.id}" {eq name="info['qudao']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>区域</label>
                    <select class="form-control" name="area" id="area"  onchange="loadRegion('area','parent_id','yiyuan','{:url('Ajax/getRegion')}');">
                        <option value="">请选择</option>
                        {volist name='area' id='data'}
                        <option value="{$data.id}" {eq name="info['area']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>收集医院</label>
                    <select class="form-control" name="yiyuan"  id="yiyuan">
                        <option value="">请选择</option>
                        {volist name='yiyuan' id='data'}
                        <option value="{$data.id}" {eq name="info['yiyuan']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>门诊</label>
                    <select class="form-control" name="menzhen" id="menzhen">
                        <option value="">请选择</option>
                        {volist name='menzhen' id='data'}
                        <option value="{$data.id}" {eq name="info['menzhen']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>收集日期</label>
                    <input type="text" name="jdtime" onclick="laydate()" {neq name="info.jdtime" value="1970-01-01"}value="{$info.jdtime}"{/neq}>
                </div>

                <div class="form-group f_g_box">
                    <label>渠道备注</label>
                    <textarea type="text" rows="5" name="qdbz" >{$info.qdbz}</textarea>
                </div>
                <br>
                <br>
                <i><h4>活动信息：</h4></i>
                <br>
                <div class="form-group f_g_box">
                    <label>活动门店</label>
                    <select class="form-control" name="hsdzid">
                        <option value="">请选择</option>
                        {volist name='hdmd' id='data'}
                        <option value="{$data.id}"  {eq name="info['hsdzid']" value="$data.id"}selected="selected"{/eq} >{$data.title}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>会所专员</label>
                    <select class="form-control" name="hszyid">
                        <option value="">请选择</option>
                        {volist name='hszy' id='data'}
                        <option value="{$data.id}" {eq name="info['hszyid']" value="$data.id"}selected="selected"{/eq} >{$data.username}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>活动状态</label>
                    <select class="form-control" name="hdstate">
                        <option value="">请选择</option>
                        {volist name='hsstate' id='data'}
                        <option value="{$data.id}"  {eq name="info['hdstate']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group f_g_box">
                    <label>课程</label>
                    <select class="form-control" name="kcid">
                        <option value="">请选择</option>
                        {volist name='kecheng' id='data'}
                        <option value="{$data.id}" {eq name="info['kcid']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                        {/volist}
                    </select>
                </div>
                <br>
                <i><h4>自动推送开关：</h4></i>
                <div class="form-group f_g_box">
                    <label>微信开关:</label>
                    <label style="width:20px;">开</label><input type="radio" name="wxkg"  value="1"  style="width:50px;height:25px;"  >
                    <label style="width:20px;">关</label><input type="radio" name="wxkg"  value="0" checked style="width:25px;height:25px;"  >
                </div>
                <div class="btn_t">
                    <button id="submit">确定</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- 搜索 结束 -->
<!-- 列表 -->
{/block}

{block name="js"}
<script src="__JS__/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="__STATIC__/layui/layui.js"></script>
<script type="text/javascript" src="__JS__/calendar.js"></script>
<script type="text/javascript" src="__JS__/region.js"></script>
<script src="__JS__/bootstrap.min.js"></script>
<script src="__JS__/bootstrapValidator.min.js"></script>
<script src="__JS__/language/zh_CN.js"></script>
<script type="text/javascript" src="__JS__/yewu.js"></script>
<script type="text/javascript" src="__JS__/chachong.js"></script>

<script type="text/javascript">
    $(function () {

        $('#yctime').click(function () {
            var bootstrapValidator = $("#commentForm").data('bootstrapValidator');
            bootstrapValidator.updateStatus('yctime', 'NOT_VALIDATED').validateField('yctime'); //错误提示信息变了
        });

        $('#commentForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
            },
            fields: {
                name: {
                    message: '用户名验证失败',
                    validators: {
                        notEmpty: {
                            message: '用户名不能为空'
                        }
                    }
                },
                maphone: {
                    validators: {
                        notEmpty: {
                            message: '妈妈电话不能为空'
                        },
                        stringLength: {
                            min: 11,
                            max: 11,
                            message: '请输入11位手机号码'
                        },
                        regexp: {
                            regexp: /^1[3|5|8]{1}[0-9]{9}$/,
                            message: '请输入正确的手机号码'
                        }
                    }
                },
                yctime: {
                    validators: {
                        notEmpty: {
                            message: '预产期不能为空'
                        },
                        date : {
                            format : "YYYY-MM-DD",
                            message : "预产期格式不正确"         }
                    }
                },
                qxpstime:{
                    validators: {
                        notEmpty: {
                            message: '预产期不能为空'
                        },
                        date : {
                            format : "YYYY-MM-DD",
                            message : "预产期格式不正确"         }
                    }
                },
                fenlei: {
                    validators: {
                        notEmpty: {
                            message: '分类不能为空'
                        }
                    }
                },
                qudao: {
                    validators: {
                        notEmpty: {
                            message: '渠道不能为空'
                        }
                    }
                },
                area: {
                    validators: {
                        notEmpty: {
                            message: '区域不能为空'
                        }
                    }
                },
                yiyuan: {
                    validators: {
                        notEmpty: {
                            message: '医院不能为空'
                        }
                    }
                },
                menzhen: {
                    validators: {
                        notEmpty: {
                            message: '医院渠道不能为空'
                        }
                    }
                }
            }
        });
        $(document).keyup(function(event){
            if(event.keyCode ==13){
                $("#submit").trigger("click");
            }
        });
        $("#commentForm").submit(function(ev){ev.preventDefault();});
        $("#submit").on("click", function(){
            var bootstrapValidator = $("#commentForm").data('bootstrapValidator');
            bootstrapValidator.validate();
            if(bootstrapValidator.isValid()){

                $.ajax({
                    type: "POST",
                    url:  "{:url('edit')}",
                    data: $('#commentForm').serialize(),
                    beforeSend:function(){
                        $(this).attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
//                        console.log(msg);
//                        alert(msg.status);
                        if(msg.status==1){
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.info, {icon: 1});
                            setTimeout(function(){
                                location.href="{:url('index/listing')}";
                            },3000); //延迟演示
                        }else{
                            layer.msg(msg.info, {icon: 2});
                            $('#submit').removeAttr("disabled"); //禁止点击
                        }

                    }
                });
                return false;
            }else return;
        });
    });
    /*$().ready(function() {
        // 在键盘按下并释放及提交后验证提交表单
        $("#commentForm").validate({
            /!*rules: {
             name: { required:true
             },
             phone: {
             isMobile : true
             },
             jdtime:{
             dataTime : true
             }
             },
             messages: {
             name: "请输入顾客姓名!",
             phone: "请输入正确手机号码！",
             jdtime:"请填写正确的进店时间"

             },*!/
            submitHandler: function(form)
            {

                $.ajax({
                    type: "POST",
                    url:  "{:url('add_list')}",
                    data: $(form).serialize(),
                    beforeSend:function(){
                        //alert(data);
                        // $(".alert-success").css({'display':'block'});
                        $('#submit').attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
                        //console.log(msg);
                       // alert(msg.status);
                        if(msg.status==1){
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.info, {icon: 1});
                            setTimeout(function(){
                                location.href="{:url('index/listing')}";
                            },3000); //延迟演示
                        }else{
                            layer.msg(msg.info, {icon: 2});
                            $('#submit').removeAttr("disabled"); //禁止点击
                        }
                    }
                });
            }

        });
        return false;
    });*/
</script>
{/block}

